﻿// -----------------------------------------------------------------------
//  <copyright file="ServiceProviderExtensions.cs" company="LiuliuSoft">
//      Copyright (c) 2025 66SOFT. All rights reserved.
//  </copyright>
//  <site>https://ifs.66soft.net</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025-09-27 14:09</last-date>
// -----------------------------------------------------------------------

namespace DaprPlus.Identity;

public static class ServiceProviderExtensions
{
    public static async Task<OnlineUser?> GetOnlineUser(this IServiceProvider provider)
    {
        var onlineUserProvider = provider.GetService<IOnlineUserProvider>();
        if (onlineUserProvider == null)
        {
            return null;
        }

        var onlineUser = await onlineUserProvider.GetAsync();
        return onlineUser;
    }
}